/**
 * 材料库管理 api js
 */
import request from "@/utils/request";

const baseURL = process.env.VUE_APP_BASE_API;

/**
 * 查询分页数据
 * @param {*} params
 */
export function queryPages(params) {
  return request({
    url:
      process.env.VUE_APP_KSTB_ROUTE_PATH + "/yxpz/materialsStore/queryPages",
    method: "get",
    params: params
  });
}

/**
 * 保存或修改材料库材料
 * @param {*} data
 */
export function saveOrUpdate(data) {
  return request({
    url:
      process.env.VUE_APP_KSTB_ROUTE_PATH + "/yxpz/materialsStore/saveOrUpdate",
    method: "post",
    headers: {
      "Content-Type": "application/json;charset=UTF-8"
    },
    data: data
  });
}

/**
 * 切换材料状态
 * @param {*} params
 * @returns
 */
export function tiggerState(params) {
  return request({
    url:
      process.env.VUE_APP_KSTB_ROUTE_PATH + "/yxpz/materialsStore/tiggerState",
    method: "get",
    params: params
  });
}

/**
 * 通过id查询
 * @param {*} id
 * @returns
 */
export function queryById(id) {
  return request({
    url:
      process.env.VUE_APP_KSTB_ROUTE_PATH +
      `/yxpz/materialsStore/queryById/${id}`,
    method: "post",
    headers: {
      "Content-Type": "application/json;charset=UTF-8"
    }
  });
}

/**
 * 根据materialOid 查询材料库数据
 * @param {*} materialOid
 */
export function queryByMaterialOid(materialOid) {
  return request({
    url:
      process.env.VUE_APP_KSTB_ROUTE_PATH +
      `/yxpz/materialsStore/queryByMaterialOid/${materialOid}`,
    method: "post",
    headers: {
      "Content-Type": "application/json;charset=UTF-8"
    }
  });
}

/**
 * 通过id删除
 * @param {*} id
 */
export function del(id) {
  return request({
    url:
      process.env.VUE_APP_KSTB_ROUTE_PATH +
      `/yxpz/materialsStore/deleteById/${id}`,
    method: "post",
    headers: {
      "Content-Type": "application/json;charset=UTF-8"
    }
  });
}

/**
 * 设置材料库的证照目录oid
 * @param {*} id
 * @param {*} shareLicenseOid
 * @returns
 */
export function setShareLicense(id, shareLicenseOid) {
  return request({
    url:
      process.env.VUE_APP_KSTB_ROUTE_PATH +
      "/yxpz/materialsStore/setShareLicense",
    method: "get",
    params: {
      id: id,
      shareLicenseOid: shareLicenseOid
    }
  });
}

/**
 * 根据条件查询材料库数据
 * @param {*} params
 */
export function queryListMaterialsStore(params) {
  return request({
    url:
      process.env.VUE_APP_KSTB_ROUTE_PATH +
      "/yxpz/materialsStore/queryListMaterialsStore",
    method: "get",
    params: params
  });
}

/**
 * 通过材料库主键oid查询是否关联了清单中未删除的材料
 * @param {*} materialOid
 */
export function hasRelMaterials(materialOid = "") {
  return request({
    url:
      process.env.VUE_APP_KSTB_ROUTE_PATH +
      `/yxpz/materialsStore/hasRelMaterials/${materialOid}`,
    method: "post",
    headers: {
      "Content-Type": "application/json;charset=UTF-8"
    }
  });
}
